<?php

$fn='x11.txt';

$txt = file_get_contents($fn);

$delimiter='作品正文';
$arr=explode($delimiter, $txt);

$idx=0;
$max=3000;

$fnidx=0;
$buff='';

// 异界流氓天尊
foreach ($arr as $key => $value) {
	$idx++;
	$buff .= $delimiter. '分割 第' .$idx .'章 ' . $value;	
	if($idx>=$max){		
		$fnidx++;
		$buff .= ' count:'.$idx;
		file_put_contents('x2异界流氓天尊_'.$fnidx.'.txt', $buff);

		$buff='';
		$idx=0;
	}
}

$buff .= ' count:'.$idx;
$fnidx++;
file_put_contents('x2异界流氓天尊_'.$fnidx.'.txt', $buff);

?>